package com.prj.ufdm.cloud.ms.warehouse.api.inventory;

import java.util.List;
import java.util.UUID;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;
import com.prj.ufdm.cloud.ms.warehouse.dao.inventory.InventoryDao;
import com.prj.ufdm.cloud.ms.warehouse.model.inventory.Inventory;

/**
 * DESC: 库存管理 <br>
 * @author 胡义振
 * @date 2020年2月23日
 */
@RestController
@RequestMapping("/api/warehouse/inventory")
public class InventoryApi {
	
	@Autowired
	private InventoryDao inventoryDao;
	
	@RequestMapping("/list")
	@ResponseBody
	public List<Inventory> getNewsList(Inventory inventory) {
		return inventoryDao.selectInventoryList(inventory);
	}
	
	@RequestMapping("/add")
	@ResponseBody
	public int saveNews(Inventory inventory) {
		inventory.setId(UUID.randomUUID().toString().replaceAll("-", "").toUpperCase());
		return inventoryDao.insertInventory(inventory);
	}
	
	@RequestMapping("/update")
	@ResponseBody
	public int modifyNews(Inventory inventory) {
		return inventoryDao.updateInventory(inventory);
	}
	
	@RequestMapping("/del")
	@ResponseBody
	public int removeNews(String id) {
		return inventoryDao.deleteInventory(id);
	}
	

}
